package soccer.stats

import com.google.common.base.Objects
import org.codehaus.groovy.grails.commons.ConfigurationHolder as CH

class PlayerHistory {
    Date transferInDate
    Date transferOutDate
    boolean currentTeam
    String mainPosition
    int squadNumber
    String personRole

    static belongsTo = [
            player: Person,
            team: Team
    ]

    static mapping = {
        cache true
    }

    static constraints = {
        transferInDate nullable: true
        transferOutDate nullable: true
        currentTeam nullable: false
        mainPosition nullable: true
        squadNumber nullable: true
        player nullable: false
        team nullable: false
        personRole nullable: false, inList: CH.config.com.singhanuvrat.soccerstats.playerRoles
    }

    def String toString() {
        return Objects.toStringHelper(this).add("Player", player).add("Team",team).add("CurrentTeam", currentTeam).add("SquadNumber", squadNumber).add("MainPosition", mainPosition).add("TransferInDate", transferInDate).add("TransferOutDate", transferOutDate).add("PersonRole", personRole).toString()
    }
}
